package us.versus.them.stickler;

class Limb {
	public var start : Vertlet;
	public var stop : Vertlet;

	public var distance : Float;

	public var delta : Point;

	public function new( start : Vertlet, stop : Vertlet ) {
		this.start = start;
		this.stop = stop;
		this.distance = Point.distance( start.current, stop.current );
		this.delta = new Point( 0, 0, 0 );
	}

	public function satisfy() {
		Point.minus( this.delta, this.stop.current, this.start.current );
		var delta_length = Math.sqrt( Point.dot( this.delta, this.delta ) );

		var diff = ( delta_length - this.distance ) / delta_length;

		Point.scale( this.delta, 0.5 * diff );
		Point.addTo(               start.current, this.delta );
		Point.subtractFrom(        stop.current,  this.delta );

		//x1 -= delta*0.5*diff;
		//x2 += delta*0.5*diff;
	}
}
